<template>
  <el-dialog title="风险单元详情" :visible.sync="visible" width="50%" :before-close="handleClose">
    <el-form :model="formData" label-position="right">
      <el-form-item label="风险分析单元名称" :label-width="formLabelWidth">
        <el-input v-model="formData.riskUnitName" readonly style="width:90%;" />
      </el-form-item>
      
      <el-form-item label="风险分析对象" :label-width="formLabelWidth">
        <el-input v-model="formData.oName" readonly style="width:90%;" />
      </el-form-item>

      <el-form-item label="责任部门" :label-width="formLabelWidth">
        <el-input v-model="formData.hazardDep" readonly style="width:90%;" />
      </el-form-item>

      <el-form-item label="责任人" :label-width="formLabelWidth">
        <el-input v-model="formData.hazardLiablePerson" readonly style="width:90%;" />
      </el-form-item>

      <el-form-item label="是否停运" :label-width="formLabelWidth">
        <el-input v-model="formData.ifStop_TEXT" readonly style="width:90%;" />
      </el-form-item>

      <el-form-item label="创建时间" :label-width="formLabelWidth">
        <el-input v-model="formData.createDate" readonly style="width:90%;" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleClose">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { useRiskUnitApi } from '@/api/riskUnitApi';

export default {
  name: 'LookAnalysis',
  data() {
    return {
      visible: false,
      formLabelWidth: '150px',
      formData: {
        id: '',
        riskUnitName: '',
        oId: '',
        oName: '',
        hazardDep: '',
        hazardDepId: '',
        hazardLiablePerson: '',
        hazardLiablePersonId: '',
        ifStop: '0',
        ifStop_TEXT: '',
        deleted: '0',
        createDate: '',
        createBy: ''
      }
    }
  },
  methods: {
    show(row) {
      this.visible = true;
      this.$nextTick(() => {
        // 查询详情
            const stopMap = {
              '0': '正常',
              '1': '停运'
            };
            this.formData = { 
              ...row,
              ifStop_TEXT: stopMap[row.ifStop] || row.ifStop
            };
        
      });
    },
    handleClose() {
      this.visible = false;
      // 重置表单数据
      this.formData = {
        id: '',
        riskUnitName: '',
        oId: '',
        oName: '',
        hazardDep: '',
        hazardDepId: '',
        hazardLiablePerson: '',
        hazardLiablePersonId: '',
        ifStop: '0',
        ifStop_TEXT: '',
        deleted: '0',
        createDate: '',
        createBy: ''
      };
    }
  }
}
</script>

<style scoped>
.el-input.is-disabled .el-input__inner {
  color: #606266;
  background-color: #fff;
  border-color: #DCDFE6;
}
</style> 